/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = 'regional';
  @endpointMap = {
    cn-hangzhou = 'mt.cn-hangzhou.aliyuncs.com',
    ap-northeast-1 = 'mt.aliyuncs.com',
    ap-northeast-2-pop = 'mt.aliyuncs.com',
    ap-south-1 = 'mt.aliyuncs.com',
    ap-southeast-1 = 'mt.ap-southeast-1.aliyuncs.com',
    ap-southeast-2 = 'mt.aliyuncs.com',
    ap-southeast-3 = 'mt.aliyuncs.com',
    ap-southeast-5 = 'mt.aliyuncs.com',
    cn-beijing = 'mt.aliyuncs.com',
    cn-beijing-finance-1 = 'mt.aliyuncs.com',
    cn-beijing-finance-pop = 'mt.aliyuncs.com',
    cn-beijing-gov-1 = 'mt.aliyuncs.com',
    cn-beijing-nu16-b01 = 'mt.aliyuncs.com',
    cn-chengdu = 'mt.aliyuncs.com',
    cn-edge-1 = 'mt.aliyuncs.com',
    cn-fujian = 'mt.aliyuncs.com',
    cn-haidian-cm12-c01 = 'mt.aliyuncs.com',
    cn-hangzhou-bj-b01 = 'mt.aliyuncs.com',
    cn-hangzhou-finance = 'mt.aliyuncs.com',
    cn-hangzhou-internal-prod-1 = 'mt.aliyuncs.com',
    cn-hangzhou-internal-test-1 = 'mt.aliyuncs.com',
    cn-hangzhou-internal-test-2 = 'mt.aliyuncs.com',
    cn-hangzhou-internal-test-3 = 'mt.aliyuncs.com',
    cn-hangzhou-test-306 = 'mt.aliyuncs.com',
    cn-hongkong = 'mt.aliyuncs.com',
    cn-hongkong-finance-pop = 'mt.aliyuncs.com',
    cn-huhehaote = 'mt.aliyuncs.com',
    cn-north-2-gov-1 = 'mt.aliyuncs.com',
    cn-qingdao = 'mt.aliyuncs.com',
    cn-qingdao-nebula = 'mt.aliyuncs.com',
    cn-shanghai = 'mt.aliyuncs.com',
    cn-shanghai-et15-b01 = 'mt.aliyuncs.com',
    cn-shanghai-et2-b01 = 'mt.aliyuncs.com',
    cn-shanghai-finance-1 = 'mt.aliyuncs.com',
    cn-shanghai-inner = 'mt.aliyuncs.com',
    cn-shanghai-internal-test-1 = 'mt.aliyuncs.com',
    cn-shenzhen = 'mt.aliyuncs.com',
    cn-shenzhen-finance-1 = 'mt.aliyuncs.com',
    cn-shenzhen-inner = 'mt.aliyuncs.com',
    cn-shenzhen-st4-d01 = 'mt.aliyuncs.com',
    cn-shenzhen-su18-b01 = 'mt.aliyuncs.com',
    cn-wuhan = 'mt.aliyuncs.com',
    cn-yushanfang = 'mt.aliyuncs.com',
    cn-zhangbei-na61-b01 = 'mt.aliyuncs.com',
    cn-zhangjiakou = 'mt.aliyuncs.com',
    cn-zhangjiakou-na62-a01 = 'mt.aliyuncs.com',
    cn-zhengzhou-nebula-1 = 'mt.aliyuncs.com',
    eu-central-1 = 'mt.aliyuncs.com',
    eu-west-1 = 'mt.aliyuncs.com',
    eu-west-1-oxs = 'mt.aliyuncs.com',
    me-east-1 = 'mt.aliyuncs.com',
    rus-west-1-pop = 'mt.aliyuncs.com',
    us-east-1 = 'mt.aliyuncs.com',
    us-west-1 = 'mt.aliyuncs.com',
  };

  checkConfig(config);
  @endpoint = getEndpoint('alimt', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model GetResourceResponseBody = {
  code?: string(name='Code'),
  data?: string(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model GetResourceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetResourceResponseBody(name='body'),
}

/**
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetResourceResponse
 */
async function getResourceWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): GetResourceResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'GetResource',
    version = '2019-01-02',
    protocol = 'HTTPS',
    pathname = `/api/resource`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @return GetResourceResponse
 */
async function getResource(): GetResourceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getResourceWithOptions(headers, runtime);
}

model ListMtConnectorRequest {
  userId?: long(name='UserId'),
}

model ListMtConnectorResponseBody = {
  requestId?: string(name='RequestId'),
  bizErrorCode?: long(name='bizErrorCode'),
  data?: [ 
    {
      key?: string(name='key'),
      value?: string(name='value'),
    }
  ](name='data'),
  errorMessage?: string(name='errorMessage'),
  success?: string(name='success'),
}

model ListMtConnectorResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListMtConnectorResponseBody(name='body'),
}

/**
 * @summary 获取系统模型和AI模型
 *
 * @param request ListMtConnectorRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListMtConnectorResponse
 */
async function listMtConnectorWithOptions(request: ListMtConnectorRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListMtConnectorResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.userId)) {
    query['UserId'] = request.userId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListMtConnector',
    version = '2019-01-02',
    protocol = 'HTTPS',
    pathname = `/api/alynx/listMtModels`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 获取系统模型和AI模型
 *
 * @param request ListMtConnectorRequest
 * @return ListMtConnectorResponse
 */
async function listMtConnector(request: ListMtConnectorRequest): ListMtConnectorResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listMtConnectorWithOptions(request, headers, runtime);
}

model TranslateECommerceResponseBody = {
  code?: string(name='Code'),
  data?: {
    translated?: string(name='Translated'),
    wordCount?: string(name='WordCount'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model TranslateECommerceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: TranslateECommerceResponseBody(name='body'),
}

/**
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return TranslateECommerceResponse
 */
async function translateECommerceWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): TranslateECommerceResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'TranslateECommerce',
    version = '2019-01-02',
    protocol = 'HTTPS',
    pathname = `/api/translate/web/ecommerce`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @return TranslateECommerceResponse
 */
async function translateECommerce(): TranslateECommerceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return translateECommerceWithOptions(headers, runtime);
}

model TranslateGeneralResponseBody = {
  code?: string(name='Code'),
  data?: {
    translated?: string(name='Translated'),
    wordCount?: string(name='WordCount'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
}

model TranslateGeneralResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: TranslateGeneralResponseBody(name='body'),
}

/**
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return TranslateGeneralResponse
 */
async function translateGeneralWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): TranslateGeneralResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'TranslateGeneral',
    version = '2019-01-02',
    protocol = 'HTTPS',
    pathname = `/api/translate/web/general`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @return TranslateGeneralResponse
 */
async function translateGeneral(): TranslateGeneralResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return translateGeneralWithOptions(headers, runtime);
}

